float ox,oy;
void setup(){
  size(500, 500);
  background (0);
  noLoop();
}
void drawAxes(PGraphics shape){
  shape.line(shape.width/2,30,shape.width/2,shape.height-30);
  shape.triangle(shape.width-30,shape.height/2-3,shape.width-24,shape.height/2,shape.width-30,shape.height/2+3);
  shape.line(30,shape.height/2,shape.width-30,shape.height/2);
  shape.triangle(shape.width/2,24,shape.width/2-3,30,shape.width/2+3,30);
}
void drawPow(PGraphics shape,float base,float scale){
  shape.noFill();
  shape.beginShape();
  for(int i=0;i<shape.width;i++){
    float x=(i-shape.width/2)/scale;
    float y=pow(base,x);
    println("x:"+x+"-y:"+y*scale);
    if(i!=0){
      shape.curveVertex(i,shape.height/2-y*scale);
    }
  } 
  shape.endShape();
}
void drawLogarithm(PGraphics shape,float base,float scale){
  shape.noFill();
  shape.beginShape();
  for(int i=shape.width/2+1;i<shape.width;i++){
    float x=(i-shape.width/2)/scale;
    float y=log(x)/log(base);
    println("x:"+x+"-y:"+y*scale);
    if(i!=0){
      shape.curveVertex(i,shape.height/2-y*scale);
    }
  }
  shape.endShape();
}
void drawQuadratic(PGraphics shape,float pa,float pb,float pc,float scale){
  shape.noFill();
  shape.beginShape();
  for(int i=0;i<shape.width;i++){
    float x=(i-shape.width/2)/scale;
    float y=pa*x*x+pb*x+pc;
    //println("x:"+x+"-y:"+y*scale);
    if(i!=0){
      shape.curveVertex(i,shape.height/2-y*scale);
    }
  }
  shape.endShape();
}
void draw(){
  PGraphics cd=createGraphics(200,200);
  cd.beginDraw();
  cd.background(255);
  cd.stroke(0,255,0);
  cd.fill(0,255,0);
  drawAxes(cd);
  cd.stroke(255,0,0);
  drawQuadratic(cd,-1,-3,-5,5);
  drawQuadratic(cd,1,3,-5,5);
  drawPow(cd,3,50);
  cd.endDraw();
  image(cd,30,30);
  PGraphics pg=createGraphics(200,200);
  pg.beginDraw();
  pg.background(255);
  pg.stroke(0,255,0);
  drawAxes(pg);
  pg.stroke(255,0,0);
  drawQuadratic(pg,1,-3,-5,5);
  drawQuadratic(pg,-1,3,-5,5);
  pg.stroke(255,0,255);
  drawPow(pg,0.3,50);
  pg.endDraw();
  image(pg,230,230);
}
